// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from 'STORES'
import VueResource from 'vue-resource'
import teaheader from '@/components/teacher/common/teaheader'
import teafooter from '@/components/teacher/common/teafooter'
import searchToMap from '@/utils/searchToMap'
import dataform from '@/utils/dataformat'
Vue.component('teaheader', teaheader)
Vue.component('teafooter', teafooter)
Vue.config.productionTip = false
Vue.use(VueResource)
localStorage.clear();
Vue.http.options.emulateJSON = true;
const search = searchToMap();
if(location.search && search.tbkt_token) {
	localStorage.setItem('Tbkt-Token', search.tbkt_token);
} else {
	try {
		let token = appobject.returnTbktToken();
		localStorage.setItem('Tbkt-Token', token);
	} catch(e) {}
}

Vue.http.interceptors.push(function(request, next) {
	let tbkt_token = localStorage.getItem("Tbkt-Token") || search.tbkt_token || '';
	if(tbkt_token) request.headers.map['Tbkt-Token'] = [tbkt_token];
	next(function(response) {
		return response
	})
})
/* eslint-disable no-new */
new Vue({
	el: '#app',
	router,
	store,
	template: '<App/>',
	components: {
		App
	}
})
